
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import App.*;
import java.awt.*;
import java.awt.event.*;

/**
 *
 * @author Jaso
 */
public class AccountPanel extends Panel implements ActionListener{
    private Button logOffBtn, btnLogoff, btnWithdraw, btnDeposit;
    private Container pane;
    private Label lblCurrentBalance;
    private Panel cards, panelContainer;
    private CardLayout cardLayout;

    private GUI gui;
    private double currentBalance;
    private int width;
    
    
    public AccountPanel(Facada facada) {
        panelContainer = new Panel();
        width = 700;
        initComponent();
    }
    
    public void initComponent()	{
        this.setBackground(new Color(143, 188, 143));  
        this.setSize(width,500);
        this.setLayout(null);
        

        
        lblCurrentBalance = new Label("Current Balance: "+ currentBalance);
        lblCurrentBalance.setFont(new Font("Serif", Font.PLAIN, 30));
        lblCurrentBalance.setForeground (new Color (173, 255, 47));
        lblCurrentBalance.setBounds(width/2-160, 120, 320  , 50);
        add(lblCurrentBalance);
        
        
        
        btnWithdraw = new Button("Withdraw");
        btnWithdraw.addActionListener(this);
        btnWithdraw.setBackground(new Color(189, 183, 107));
        btnWithdraw.setFont(new Font("Serif", Font.PLAIN, 30));
        btnWithdraw.setBounds(width/2- 100, 200, 200  , 75);

        add(btnWithdraw);
        
        
        btnDeposit = new Button("Deposit");
        btnDeposit.addActionListener(this);
        btnDeposit.setBackground(new Color(189, 183, 107));
        btnDeposit.setFont(new Font("Serif", Font.PLAIN, 30));
        btnDeposit.setBounds(width/2-100, 300, 200  , 75);

        add(btnDeposit);

    }

    public void updateCurrentBalance(double balance)  {
        lblCurrentBalance.setText("Current Balance: "+ balance);
    }
    
    
    @Override
    public void actionPerformed(ActionEvent e) {
        
        if(e.getSource() == btnWithdraw)   {
            gui.SwitchPanels("WithdrawPanel");
        } else if(e.getSource() == btnDeposit)   {
            gui.SwitchPanels("DepositPanel");
        }  
    }

    
    /**
     * @return the CurrentBalance
     */
    public double getCurrentBalance() {
        return currentBalance;
    }

    /**
     * @param CurrentBalance the CurrentBalance to set
     */
    public void setCurrentBalance(double CurrentBalance) {
        this.currentBalance = CurrentBalance;
    }

    /**
     * @param gui the gui to set
     */
    public void setGui(GUI gui) {
        this.gui = gui;
    }


}
